package com.mesSystem.controller;


import com.mesSystem.dto.ProcessWorkstationRequest;
import com.mesSystem.dto.Result;
import com.mesSystem.entity.ProcessWorkstation;
import com.mesSystem.service.impl.ProcessWorkstationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("processWorkstation")
public class ProcessWorkstationManagementController {
    @Autowired
    ProcessWorkstationService processWorkstationService;

    /**
     * 管理（添加、删除）工序工位信息
     * @param request
     * @return
     */
    @PostMapping("management")
    public Result Management(@RequestBody ProcessWorkstationRequest request) {
        processWorkstationService.update(request.getWorkstationIds(),request.getProcessName());
        return Result.ok("更新成功");
    }

    /**
     * 根据工序名称查询工位情况
     * @param page
     * @param size
     * @param processName
     * @return
     */
    @GetMapping("queryByProcessName")
    public Result queryWorkstation(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                    @RequestParam(value = "size", defaultValue = "10") Integer size,
                                    @RequestParam(value = "processName") String processName) {
        return Result.ok(processWorkstationService.queryByProcessName(page, size, processName));
    }


}
